unit UntVIPObj;

interface

type
  TVIPObj = class(TObject)
  public
    class function Search(code: string; var discount: double): Boolean;
  end;

implementation

uses
  UntDMDB, Math, defineConst;

class function TVIPObj.Search(code: string; var discount: double): Boolean;
begin
  Result := False;
  discount :=1;
  with DMMySQL.myqryCom do
  begin
    Close;
    try
      SQL.Clear;
      SQL.Add('select * from vip where `code`=:codeNO or phone=:phone');
      ParamByName('codeNO').AsString := code;
      ParamByName('phone').AsString := code;
      Open;
      if not IsEmpty then
      begin
        discount := FieldByName('discount').AsFloat;
        RoundTo(discount,cDecimalDigits);
        if(discount>0) and (discount<1) then
          Result := True;
      end;
    finally
      Close;
    end;
  end;
end;

end.
